<?
//рус
$this->baseUrl = rtrim(preg_replace('/([?,&])page=[^&]*[&]?/is', '$1', $this->baseUrl), '&');
if (strpos($this->baseUrl, '?') === false)
    $this->baseUrl .= '?';
else
    $this->baseUrl .= '&';
?>
<a href="<?=$this->baseUrl;?>page=<?=($this->page - 1);?>" class="next">&lt;</a>
<?
$surr = 4;
$start = max(2, $this->page - $surr);
$end = min($this->totalPages - 1, $this->page + $surr);
$sPages = array();
if ($start <= $end)
    $sPages = range($start, $end);
array_unshift($sPages, 1);
array_push($sPages, $this->totalPages);
for ($i = 0; $i < sizeof($sPages); $i ++) {
    ?>
<a href="<?=$this->baseUrl;?>page=<?=($sPages[$i]);?>"
	<?=($sPages[$i] == $this->page ? ' class="cur"' : '');?>><?=$sPages[$i];?></a>
<?
    if (isset($sPages[$i + 1]) && (($sPages[$i] + 1) != $sPages[$i + 1])) {
        ?>
<span>&hellip;</span>
<?
    }
}
?>
<a href="<?=$this->baseUrl;?>page=<?=($this->page + 1);?>" class="next">></a>